package com.dz.finance.biz.service.impl;

import com.dz.finance.biz.config.ObjectConvertor;
import com.dz.finance.biz.entity.Member;
import com.dz.finance.biz.service.MemberComService;
import com.dz.finance.biz.service.MemberService;
import com.dz.finance.biz.vo.CurrentInfoVo;
import com.dz.finance.common.entity.Token;
import com.dz.finance.common.entity.User;
import com.dz.finance.common.service.UserTokenService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author: DengHaoQi
 * @date: 2024/7/1 15:43
 * @description:
 */

@Service
@RequiredArgsConstructor
public class MemberComServiceImpl implements MemberComService {

    private final MemberService memberService;
    private final ObjectConvertor objectConvertor;
    private final UserTokenService<User> userTokenService;

    /*
    * 获取当前登陆用户
    * */
    @Override
    public CurrentInfoVo currentUser() {
        Member condition = new Member();
        condition.setId(userTokenService.getThreadLocalUserId());
        Member member = memberService.getMember(condition);
        return objectConvertor.toCurrentInfoVo(member);
    }
}
